package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.Map;
@Controller
public class LoginController {

    @RequestMapping("/showLogin")
    public ModelAndView show(){
        System.out.println("LoginController.show()");
        return new ModelAndView("login");
    }


    @RequestMapping("/login")
    public String login(String username, String password, Map map, HttpSession session){
        System.out.println("LoginController.login()");

        System.out.println("username = " + username);
        System.out.println("password = " + password);

        if("abc".equals(username)&&"123".equals(password)){
            session.setAttribute("user",username);
            return "redirect:/showSuccess";
        }
        map.put("message","用户名或密码错误");
        return "login";
    }










}
